\(\int \csc ^3(c+d x) (a+b \tan (c+d x))^2 \, dx\) [28]

   Optimal result
   Rubi [A] (verified)
   Mathematica [B] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 21, antiderivative size = 95 \[ \int \csc ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=-\frac {a^2 \text {arctanh}(\cos (c+d x))}{2 d}-\frac {b^2 \text {arctanh}(\cos (c+d x))}{d}+\frac {2 a b \text {arctanh}(\sin (c+d x))}{d}-\frac {2 a b \csc (c+d x)}{d}-\frac {a^2 \cot (c+d x) \csc (c+d x)}{2 d}+\frac {b^2 \sec (c+d x)}{d} \]

[Out]

-1/2*a^2*arctanh(cos(d*x+c))/d-b^2*arctanh(cos(d*x+c))/d+2*a*b*arctanh(sin(d*x+c))/d-2*a*b*csc(d*x+c)/d-1/2*a^
2*cot(d*x+c)*csc(d*x+c)/d+b^2*sec(d*x+c)/d

Rubi [A] (verified)

Time = 0.12 (sec) , antiderivative size = 95, normalized size of antiderivative = 1.00, number of steps used = 10, number of rules used = 7, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.333, Rules used = {3598, 3853, 3855, 2701, 327, 213, 2702} \[ \int \csc ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=-\frac {a^2 \text {arctanh}(\cos (c+d x))}{2 d}-\frac {a^2 \cot (c+d x) \csc (c+d x)}{2 d}+\frac {2 a b \text {arctanh}(\sin (c+d x))}{d}-\frac {2 a b \csc (c+d x)}{d}-\frac {b^2 \text {arctanh}(\cos (c+d x))}{d}+\frac {b^2 \sec (c+d x)}{d} \]

[In]

Int[Csc[c + d*x]^3*(a + b*Tan[c + d*x])^2,x]

[Out]

-1/2*(a^2*ArcTanh[Cos[c + d*x]])/d - (b^2*ArcTanh[Cos[c + d*x]])/d + (2*a*b*ArcTanh[Sin[c + d*x]])/d - (2*a*b*
Csc[c + d*x])/d - (a^2*Cot[c + d*x]*Csc[c + d*x])/(2*d) + (b^2*Sec[c + d*x])/d

Rule 213

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(-(Rt[-a, 2]*Rt[b, 2])^(-1))*ArcTanh[Rt[b, 2]*(x/Rt[-a, 2])]
, x] /; FreeQ[{a, b}, x] && NegQ[a/b] && (LtQ[a, 0] || GtQ[b, 0])

Rule 327

Int[((c_.)*(x_))^(m_)*((a_) + (b_.)*(x_)^(n_))^(p_), x_Symbol] :> Simp[c^(n - 1)*(c*x)^(m - n + 1)*((a + b*x^n
)^(p + 1)/(b*(m + n*p + 1))), x] - Dist[a*c^n*((m - n + 1)/(b*(m + n*p + 1))), Int[(c*x)^(m - n)*(a + b*x^n)^p
, x], x] /; FreeQ[{a, b, c, p}, x] && IGtQ[n, 0] && GtQ[m, n - 1] && NeQ[m + n*p + 1, 0] && IntBinomialQ[a, b,
 c, n, m, p, x]

Rule 2701

Int[(csc[(e_.) + (f_.)*(x_)]*(a_.))^(m_)*sec[(e_.) + (f_.)*(x_)]^(n_.), x_Symbol] :> Dist[-(f*a^n)^(-1), Subst
[Int[x^(m + n - 1)/(-1 + x^2/a^2)^((n + 1)/2), x], x, a*Csc[e + f*x]], x] /; FreeQ[{a, e, f, m}, x] && Integer
Q[(n + 1)/2] &&  !(IntegerQ[(m + 1)/2] && LtQ[0, m, n])

Rule 2702

Int[csc[(e_.) + (f_.)*(x_)]^(n_.)*((a_.)*sec[(e_.) + (f_.)*(x_)])^(m_), x_Symbol] :> Dist[1/(f*a^n), Subst[Int
[x^(m + n - 1)/(-1 + x^2/a^2)^((n + 1)/2), x], x, a*Sec[e + f*x]], x] /; FreeQ[{a, e, f, m}, x] && IntegerQ[(n
 + 1)/2] &&  !(IntegerQ[(m + 1)/2] && LtQ[0, m, n])

Rule 3598

Int[sin[(e_.) + (f_.)*(x_)]^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_.), x_Symbol] :> Int[Expand[Sin[e
+ f*x]^m*(a + b*Tan[e + f*x])^n, x], x] /; FreeQ[{a, b, e, f}, x] && IntegerQ[(m - 1)/2] && IGtQ[n, 0]

Rule 3853

Int[(csc[(c_.) + (d_.)*(x_)]*(b_.))^(n_), x_Symbol] :> Simp[(-b)*Cos[c + d*x]*((b*Csc[c + d*x])^(n - 1)/(d*(n
- 1))), x] + Dist[b^2*((n - 2)/(n - 1)), Int[(b*Csc[c + d*x])^(n - 2), x], x] /; FreeQ[{b, c, d}, x] && GtQ[n,
 1] && IntegerQ[2*n]

Rule 3855

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps \begin{align*} \text {integral}& = \int \left (a^2 \csc ^3(c+d x)+2 a b \csc ^2(c+d x) \sec (c+d x)+b^2 \csc (c+d x) \sec ^2(c+d x)\right ) \, dx \\ & = a^2 \int \csc ^3(c+d x) \, dx+(2 a b) \int \csc ^2(c+d x) \sec (c+d x) \, dx+b^2 \int \csc (c+d x) \sec ^2(c+d x) \, dx \\ & = -\frac {a^2 \cot (c+d x) \csc (c+d x)}{2 d}+\frac {1}{2} a^2 \int \csc (c+d x) \, dx-\frac {(2 a b) \text {Subst}\left (\int \frac {x^2}{-1+x^2} \, dx,x,\csc (c+d x)\right )}{d}+\frac {b^2 \text {Subst}\left (\int \frac {x^2}{-1+x^2} \, dx,x,\sec (c+d x)\right )}{d} \\ & = -\frac {a^2 \text {arctanh}(\cos (c+d x))}{2 d}-\frac {2 a b \csc (c+d x)}{d}-\frac {a^2 \cot (c+d x) \csc (c+d x)}{2 d}+\frac {b^2 \sec (c+d x)}{d}-\frac {(2 a b) \text {Subst}\left (\int \frac {1}{-1+x^2} \, dx,x,\csc (c+d x)\right )}{d}+\frac {b^2 \text {Subst}\left (\int \frac {1}{-1+x^2} \, dx,x,\sec (c+d x)\right )}{d} \\ & = -\frac {a^2 \text {arctanh}(\cos (c+d x))}{2 d}-\frac {b^2 \text {arctanh}(\cos (c+d x))}{d}+\frac {2 a b \text {arctanh}(\sin (c+d x))}{d}-\frac {2 a b \csc (c+d x)}{d}-\frac {a^2 \cot (c+d x) \csc (c+d x)}{2 d}+\frac {b^2 \sec (c+d x)}{d} \\ \end{align*}

Mathematica [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(250\) vs. \(2(95)=190\).

Time = 2.78 (sec) , antiderivative size = 250, normalized size of antiderivative = 2.63 \[ \int \csc ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {8 b^2-8 a b \cot \left (\frac {1}{2} (c+d x)\right )-a^2 \csc ^2\left (\frac {1}{2} (c+d x)\right )-4 \left (a^2+2 b^2\right ) \log \left (\cos \left (\frac {1}{2} (c+d x)\right )\right )-16 a b \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )+4 \left (a^2+2 b^2\right ) \log \left (\sin \left (\frac {1}{2} (c+d x)\right )\right )+16 a b \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )+a^2 \sec ^2\left (\frac {1}{2} (c+d x)\right )+\frac {8 b^2 \sin \left (\frac {1}{2} (c+d x)\right )}{\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )}-\frac {8 b^2 \sin \left (\frac {1}{2} (c+d x)\right )}{\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )}-8 a b \tan \left (\frac {1}{2} (c+d x)\right )}{8 d} \]

[In]

Integrate[Csc[c + d*x]^3*(a + b*Tan[c + d*x])^2,x]

[Out]

(8*b^2 - 8*a*b*Cot[(c + d*x)/2] - a^2*Csc[(c + d*x)/2]^2 - 4*(a^2 + 2*b^2)*Log[Cos[(c + d*x)/2]] - 16*a*b*Log[
Cos[(c + d*x)/2] - Sin[(c + d*x)/2]] + 4*(a^2 + 2*b^2)*Log[Sin[(c + d*x)/2]] + 16*a*b*Log[Cos[(c + d*x)/2] + S
in[(c + d*x)/2]] + a^2*Sec[(c + d*x)/2]^2 + (8*b^2*Sin[(c + d*x)/2])/(Cos[(c + d*x)/2] - Sin[(c + d*x)/2]) - (
8*b^2*Sin[(c + d*x)/2])/(Cos[(c + d*x)/2] + Sin[(c + d*x)/2]) - 8*a*b*Tan[(c + d*x)/2])/(8*d)

Maple [A] (verified)

Time = 1.81 (sec) , antiderivative size = 101, normalized size of antiderivative = 1.06

method result size
derivativedivides \(\frac {b^{2} \left (\frac {1}{\cos \left (d x +c \right )}+\ln \left (\csc \left (d x +c \right )-\cot \left (d x +c \right )\right )\right )+2 a b \left (-\frac {1}{\sin \left (d x +c \right )}+\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )\right )+a^{2} \left (-\frac {\csc \left (d x +c \right ) \cot \left (d x +c \right )}{2}+\frac {\ln \left (\csc \left (d x +c \right )-\cot \left (d x +c \right )\right )}{2}\right )}{d}\) \(101\)
default \(\frac {b^{2} \left (\frac {1}{\cos \left (d x +c \right )}+\ln \left (\csc \left (d x +c \right )-\cot \left (d x +c \right )\right )\right )+2 a b \left (-\frac {1}{\sin \left (d x +c \right )}+\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )\right )+a^{2} \left (-\frac {\csc \left (d x +c \right ) \cot \left (d x +c \right )}{2}+\frac {\ln \left (\csc \left (d x +c \right )-\cot \left (d x +c \right )\right )}{2}\right )}{d}\) \(101\)
risch \(\frac {{\mathrm e}^{i \left (d x +c \right )} \left (a^{2} {\mathrm e}^{4 i \left (d x +c \right )}+2 b^{2} {\mathrm e}^{4 i \left (d x +c \right )}-4 i a b \,{\mathrm e}^{4 i \left (d x +c \right )}+2 a^{2} {\mathrm e}^{2 i \left (d x +c \right )}-4 b^{2} {\mathrm e}^{2 i \left (d x +c \right )}+a^{2}+2 b^{2}+4 i a b \right )}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right )^{2} \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}+\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-1\right )}{2 d}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-1\right ) b^{2}}{d}+\frac {2 a b \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right )}{d}-\frac {2 a b \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{d}-\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+1\right )}{2 d}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+1\right ) b^{2}}{d}\) \(257\)

[In]

int(csc(d*x+c)^3*(a+b*tan(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

1/d*(b^2*(1/cos(d*x+c)+ln(csc(d*x+c)-cot(d*x+c)))+2*a*b*(-1/sin(d*x+c)+ln(sec(d*x+c)+tan(d*x+c)))+a^2*(-1/2*cs
c(d*x+c)*cot(d*x+c)+1/2*ln(csc(d*x+c)-cot(d*x+c))))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 230 vs. \(2 (91) = 182\).

Time = 0.31 (sec) , antiderivative size = 230, normalized size of antiderivative = 2.42 \[ \int \csc ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {8 \, a b \cos \left (d x + c\right ) \sin \left (d x + c\right ) + 2 \, {\left (a^{2} + 2 \, b^{2}\right )} \cos \left (d x + c\right )^{2} - 4 \, b^{2} - {\left ({\left (a^{2} + 2 \, b^{2}\right )} \cos \left (d x + c\right )^{3} - {\left (a^{2} + 2 \, b^{2}\right )} \cos \left (d x + c\right )\right )} \log \left (\frac {1}{2} \, \cos \left (d x + c\right ) + \frac {1}{2}\right ) + {\left ({\left (a^{2} + 2 \, b^{2}\right )} \cos \left (d x + c\right )^{3} - {\left (a^{2} + 2 \, b^{2}\right )} \cos \left (d x + c\right )\right )} \log \left (-\frac {1}{2} \, \cos \left (d x + c\right ) + \frac {1}{2}\right ) + 4 \, {\left (a b \cos \left (d x + c\right )^{3} - a b \cos \left (d x + c\right )\right )} \log \left (\sin \left (d x + c\right ) + 1\right ) - 4 \, {\left (a b \cos \left (d x + c\right )^{3} - a b \cos \left (d x + c\right )\right )} \log \left (-\sin \left (d x + c\right ) + 1\right )}{4 \, {\left (d \cos \left (d x + c\right )^{3} - d \cos \left (d x + c\right )\right )}} \]

[In]

integrate(csc(d*x+c)^3*(a+b*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

1/4*(8*a*b*cos(d*x + c)*sin(d*x + c) + 2*(a^2 + 2*b^2)*cos(d*x + c)^2 - 4*b^2 - ((a^2 + 2*b^2)*cos(d*x + c)^3
- (a^2 + 2*b^2)*cos(d*x + c))*log(1/2*cos(d*x + c) + 1/2) + ((a^2 + 2*b^2)*cos(d*x + c)^3 - (a^2 + 2*b^2)*cos(
d*x + c))*log(-1/2*cos(d*x + c) + 1/2) + 4*(a*b*cos(d*x + c)^3 - a*b*cos(d*x + c))*log(sin(d*x + c) + 1) - 4*(
a*b*cos(d*x + c)^3 - a*b*cos(d*x + c))*log(-sin(d*x + c) + 1))/(d*cos(d*x + c)^3 - d*cos(d*x + c))

Sympy [F]

\[ \int \csc ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\int \left (a + b \tan {\left (c + d x \right )}\right )^{2} \csc ^{3}{\left (c + d x \right )}\, dx \]

[In]

integrate(csc(d*x+c)**3*(a+b*tan(d*x+c))**2,x)

[Out]

Integral((a + b*tan(c + d*x))**2*csc(c + d*x)**3, x)

Maxima [A] (verification not implemented)

none

Time = 0.23 (sec) , antiderivative size = 122, normalized size of antiderivative = 1.28 \[ \int \csc ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {a^{2} {\left (\frac {2 \, \cos \left (d x + c\right )}{\cos \left (d x + c\right )^{2} - 1} - \log \left (\cos \left (d x + c\right ) + 1\right ) + \log \left (\cos \left (d x + c\right ) - 1\right )\right )} + 2 \, b^{2} {\left (\frac {2}{\cos \left (d x + c\right )} - \log \left (\cos \left (d x + c\right ) + 1\right ) + \log \left (\cos \left (d x + c\right ) - 1\right )\right )} - 4 \, a b {\left (\frac {2}{\sin \left (d x + c\right )} - \log \left (\sin \left (d x + c\right ) + 1\right ) + \log \left (\sin \left (d x + c\right ) - 1\right )\right )}}{4 \, d} \]

[In]

integrate(csc(d*x+c)^3*(a+b*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

1/4*(a^2*(2*cos(d*x + c)/(cos(d*x + c)^2 - 1) - log(cos(d*x + c) + 1) + log(cos(d*x + c) - 1)) + 2*b^2*(2/cos(
d*x + c) - log(cos(d*x + c) + 1) + log(cos(d*x + c) - 1)) - 4*a*b*(2/sin(d*x + c) - log(sin(d*x + c) + 1) + lo
g(sin(d*x + c) - 1)))/d

Giac [A] (verification not implemented)

none

Time = 0.51 (sec) , antiderivative size = 172, normalized size of antiderivative = 1.81 \[ \int \csc ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 16 \, a b \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right ) - 16 \, a b \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right ) - 8 \, a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 4 \, {\left (a^{2} + 2 \, b^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) \right |}\right ) - \frac {16 \, b^{2}}{\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1} - \frac {6 \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 12 \, b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 8 \, a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + a^{2}}{\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2}}}{8 \, d} \]

[In]

integrate(csc(d*x+c)^3*(a+b*tan(d*x+c))^2,x, algorithm="giac")

[Out]

1/8*(a^2*tan(1/2*d*x + 1/2*c)^2 + 16*a*b*log(abs(tan(1/2*d*x + 1/2*c) + 1)) - 16*a*b*log(abs(tan(1/2*d*x + 1/2
*c) - 1)) - 8*a*b*tan(1/2*d*x + 1/2*c) + 4*(a^2 + 2*b^2)*log(abs(tan(1/2*d*x + 1/2*c))) - 16*b^2/(tan(1/2*d*x
+ 1/2*c)^2 - 1) - (6*a^2*tan(1/2*d*x + 1/2*c)^2 + 12*b^2*tan(1/2*d*x + 1/2*c)^2 + 8*a*b*tan(1/2*d*x + 1/2*c) +
 a^2)/tan(1/2*d*x + 1/2*c)^2)/d

Mupad [B] (verification not implemented)

Time = 4.16 (sec) , antiderivative size = 292, normalized size of antiderivative = 3.07 \[ \int \csc ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {a^2\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2}{8\,d}+\frac {\ln \left (\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\right )\,\left (\frac {a^2}{2}+b^2\right )}{d}+\frac {{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2\,\left (\frac {a^2}{2}+8\,b^2\right )-\frac {a^2}{2}+4\,a\,b\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3-4\,a\,b\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{d\,\left (4\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2-4\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4\right )}+\frac {4\,a\,b\,\mathrm {atanh}\left (\frac {8\,a\,b^3\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{4\,a^3\,b-16\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,a^2\,b^2+8\,a\,b^3}-\frac {16\,a^2\,b^2}{4\,a^3\,b-16\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,a^2\,b^2+8\,a\,b^3}+\frac {4\,a^3\,b\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{4\,a^3\,b-16\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,a^2\,b^2+8\,a\,b^3}\right )}{d}-\frac {a\,b\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{d} \]

[In]

int((a + b*tan(c + d*x))^2/sin(c + d*x)^3,x)

[Out]

(a^2*tan(c/2 + (d*x)/2)^2)/(8*d) + (log(tan(c/2 + (d*x)/2))*(a^2/2 + b^2))/d + (tan(c/2 + (d*x)/2)^2*(a^2/2 +
8*b^2) - a^2/2 + 4*a*b*tan(c/2 + (d*x)/2)^3 - 4*a*b*tan(c/2 + (d*x)/2))/(d*(4*tan(c/2 + (d*x)/2)^2 - 4*tan(c/2
 + (d*x)/2)^4)) + (4*a*b*atanh((8*a*b^3*tan(c/2 + (d*x)/2))/(8*a*b^3 + 4*a^3*b - 16*a^2*b^2*tan(c/2 + (d*x)/2)
) - (16*a^2*b^2)/(8*a*b^3 + 4*a^3*b - 16*a^2*b^2*tan(c/2 + (d*x)/2)) + (4*a^3*b*tan(c/2 + (d*x)/2))/(8*a*b^3 +
 4*a^3*b - 16*a^2*b^2*tan(c/2 + (d*x)/2))))/d - (a*b*tan(c/2 + (d*x)/2))/d